<!-- 表格-插槽-多选查询 -->
<template>
  <div class="_pt-5 _pb-5">
    <div :style="{ maxHeight: maxHeight, overflowY: 'auto' }">
      <a-checkbox-group v-model="checkedList" :options="options" @change="handChange" />
    </div>
    <div class="_pl-8 _pr-8 _pt-8 tc">
      <a-button size="small" type="primary" @click="search">查询</a-button>
      <a-button size="small" class="_ml-8" @click="reset">重置</a-button>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Array,
      required: true,
      default: () => []
    },
    options: {
      type: Array,
      required: true,
      default: () => []
    },
    maxHeight: {
      type: String,
      default: '300px'
    }
  },
  watch: {
    value: {
      handler(val) {
        this.checkedList = val
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      checkedList: []
    }
  },
  methods: {
    handChange(e) {
      this.$emit('input', e)
    },
    search() {
      this.$emit('search')
    },
    // 重置当前筛选条件
    reset() {
      this.handChange([])
      this.search()
    }
  }
}
</script>

<style lang="less" scoped>
.tc {
  text-align: center;
}
</style>
